<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>博瑞医检(销售端)</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" href="../../css/sale/index.css" />
		<script src="../../js/vconsole.min.js"></script>
	</head>
	<style type="text/css">
	</style>
	<body>
		<div class="mui-content" id="index" v-cloak>
		    <nav class="mui-bar mui-bar-tab1">
				<a :class="{'mui-tab-item1':true,'mui-active1':active=='index'}" data-page="index">
					<span class="mui-icon iconfont icon-home"></span>
					<span class="mui-tab-label1">首页</span>
				</a>
				<a :class="{'mui-tab-item1':true,'mui-active':active=='pre'}" data-page="bespeak">
					<span class="mui-icon iconfont icon-leijiyuyue"><span class="mui-badge">{{num=='0'?'':num}}</span></span>
					<span class="mui-tab-label1">预约</span>
				</a>
				<a :class="{'mui-tab-item1':true,'mui-active':active=='mine'}" class="mui-tab-item" data-page="mine">
					<span class="mui-icon iconfont icon-wode">
						<!--<span class="mui-badge">2</span>-->
					</span>
					<span class="mui-tab-label1">我的</span>
				</a>
			</nav>
			<div id="tabbar" class="mui-control-content mui-active">
				<div class="showPanel">
			    	<div class="overflow panelTitle rel">
			    		<div class="left">
			    			<!--<img src="../../img/11.jpg" alt="avater" />-->
			    			<i class="iconfont icon-touxiang"></i>
			    			<span>{{saleData.name}}</span>
			    		</div>
			    		<div class="right abs">{{today}}</div>
			    	</div>
			    	<div class="overflow panelContainer">
			    		<div class="center">
			    			<div class="center num">{{saleData.amount}}</div>
			    			<div class="center todayCheck">今日检验金额(元)</div>
			    		</div>
			    	</div>
			    </div>
			    <div class="overflow panelContainer1">
			    		<div class="left">
			    			<div class="center num">{{saleData.actualAmount}}</div>
			    			<div class="center todayCheck">今日实收金额(元)</div>
			    		</div>
			    		<div class="right" @tap="todayOrder">
			    			<div class="center num">{{saleData.orderNumDay}}</div>
			    			<div class="center todayCheck">今日订单数</div>
			    		</div>
			    </div>
			    <div class="scan center">
			    	<div>快速查询:</div>
			    	<div><input type="text" placeholder="请扫描或输入条形码查询报告" v-model="inputCode" @focus="inputBarcode" @blur="outputBarcode" /></div>
			    	<div><span @tap="scanBarcode" :class="{'hidden':!isSearch}"><i class="iconfont icon-saomiao" ></i></span><span class="btn-primary" :class="{'hidden':isSearch}" @tap="search">查询</span></div>
			    </div>
			    <div class="workDesk">
			    	我的工作台
			    </div>
			    <ul class="mui-table-view mui-grid-view mui-grid-9">
			        <li v-for="menu in menuList" @tap="toDetail(menu.h)"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3 orderTip">
			        	<a>
			        		<span class="mui-badge" v-if="orderTip>0&&menu.n=='订单'">{{orderTip}}</span>
				            <span><img :src="menu.i"/></span>
				            <!--<span><img src="../../img/single.png"/></span>-->
				            <div class="mui-media-body">{{menu.n}}</div>
			        	</a>
			        </li>
			        <!--<li @tap="toDetail('materiel/materiel.html')" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
			        	<a>
				            <span><img src="../../img/materiel.png"/></span>
				            <div class="mui-media-body">物料</div>
			        	</a>
			        </li>-->
			    </ul> 
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/cmms.js?time=333"></script>
		<script>
			new Vue({
				el:"#index",
				data:{
					today:'',
					active:'index',
					saleData:{},
					inputCode:'',//检验条形码
					num:0,
					isSearch:true,
					orderId:'',
					orderTip:0,
					menuList:[]
				},
				mounted(){
//					var vConsole = new VConsole();
					this.init();
					this.getIndexData();
					this.muiInit();
				},
				methods:{
					init(){
						let _this=this;
						/*接口配置*/
		    			AT.muiAjax('/partner-sale/partnerSale/wxConfig','post',{url:location.href.split('#')[0]},function(res){
							wx.config({
								appId:res.appId,
								timestamp:res.timestamp,
								nonceStr:res.nonceStr,
								signature:res.signature,
								jsApiList:['scanQRCode']
							});
						});
					},
					getIndexData(){
						let _this = this;
						AT.muiAjax('/passport/getLoginUser','post',{},function(res){
							_this.menuList = res.menus;
							console.log(_this.menuList);
						});
						AT.muiAjax('/partner-sale/appointment/getNum','post',{},function(res){
							console.log(res);
							if(res>=10){
								_this.num = '9+';
							}else{
								_this.num = res;
							}
						});
						
						AT.muiAjax('/partner-sale/statistics/getHome','post',{},function(res){
							console.log(res);
							_this.saleData = res;
							_this.today = res.getTime.split('T')[0];
						});
						//未确认订单数
						AT.muiAjax('/partner-sale/order/getCountUnConfirm','post',{},function(res){
							console.log(res);
							_this.orderTip = res;
						});
					},
					muiInit(){
						let _this = this;
						mui(".mui-bar-tab1").on('tap','.mui-tab-item1',function(){
							let page = this.getAttribute('data-page');
							if(page=='bespeak'){
								location.href = "./bespeak/bespeak.html"
							}
							if(page=='mine'){
								location.href = "./mine/mine.html"
							}
						})
					},
					/*顶上今日订单*/
					todayOrder(){
						location.href="../sale/order/order.html?name=todayOrder";
					},
					toDetail(url){
						console.log(url)
						location.href = url;
					},
					getStatistics:function(){
						let _this = this;
					},
					tocheckDetail:function(){
						location.href = this.checkDetail;
					},
					search(){
						let _this = this;
						let reg=/^[A-Za-z0-9]{10,12}$/;
//						
						if(!reg.test(_this.inputCode)){
							mui.toast('条码必须为10~12位字母、数字!');
						}else{
							AT.muiAjax('/clinic-doctor/order/getOrderByServiceCode','post',{
								specimenBarCode:_this.inputCode
							},function(realData){
								console.log(realData);
								/*代码存在跳转*/
								if(realData=="false"){
									mui.alert('该条码未存在，请重新输入!');
								}else{
									_this.orderId = realData;
									location.href = "./orderDetail.html?id="+_this.orderId;
								}
							});
						}
					},
					//输入10~12位服务码
					inputBarcode:function(){
						let _this = this;
						_this.isSearch = false;
					},
					outputBarcode:function(){
						let _this = this;
						_this.isSearch = true;
					},
					//扫描10~12位服务码
					scanBarcode:function(){
						let _this = this;
						wx.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function (res) {
								AT.muiAjax('/clinic-doctor/order/getOrderByServiceCode','post',{
									specimenBarCode:_this.inputCode
								},function(realData){
									console.log(realData);
									/*代码存在跳转*/
									if(realData=="false"){
									mui.alert('该条码未存在，请重新输入!');
									}else{
										_this.orderId = realData;
										location.href = "./orderDetail.html?id="+_this.orderId;
									}
								});
							}
						});
					}
					
				}
			})
		</script>
	</body>
</html>